<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .nav {
            height: 200px;
            width: 200px;
            background-color: rgb(114, 111, 111);
        }
    </style>
</head>
<body>
    <div class="nav"></div>
</body>
<script>
    let nav = document.querySelector('.nav');
    //距离顶部的距离
    console.log(nav.offsetTop);
    console.log(nav.offsetLeft);
    console.log(nav.offsetWidth);
    console.log(nav.offsetHeight);
    //返回有定位的父亲
    console.log(nav.offsetParent);
</script>
</html>